// MySignalListDialog.cpp : implementation file
//

#include "stdafx.h"
#include "waveeditor.h"
#include "MySignalListDialog.h"


// MySignalListDialog dialog

IMPLEMENT_DYNAMIC(MySignalListDialog, CDialog)

BEGIN_MESSAGE_MAP(MySignalListDialog, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()

MySignalListDialog::MySignalListDialog(ScenarioSignals *signals,CWnd* pParent /*=NULL*/)
	: CDialog(MySignalListDialog::IDD, pParent)
{
	_globalsignals	=	signals;
}

MySignalListDialog::~MySignalListDialog()
{
}

void MySignalListDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_SIGNALSLIST, msignallist);
	msignallist.InsertColumn(0,"Signal Name",LVCFMT_LEFT,70,1);
	msignallist.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	int count=0;

	for(int i=0;i<_globalsignals->GetNumberOfSignals();i++)
	{
		if(_globalsignals->IfShowSignal(i) == FALSE)
		{
			CString name	=	_globalsignals->GetSignalName(i);
			msignallist.InsertItem(count,name);
			msignallist.SetItemText(count,0,name);
			count++;
		}
	}
}

// MySignalListDialog message handlers

void MySignalListDialog::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	POSITION pos = msignallist.GetFirstSelectedItemPosition();
	while(pos != NULL)
	{
		int item	=	msignallist.GetNextSelectedItem(pos);
		CString nm	=	msignallist.GetItemText(item,0);
		_globalsignals->AddShowSignal(nm);
	}

	OnOK();
}
